<?php
require_once(dirname(dirname(dirname(__FILE__))) . '/app.php');

need_manager();
need_auth('order');

$is_success = isset($_GET['is_success']) ? intval($_GET['is_success']) : 0;

if($is_success >0)
{
	$condition['state'] = $is_success;
}

/* end fiter */

$count = Table::Count('bonus_order', $condition);
list($pagesize, $offset, $pagestring) = pagestring($count, 20);

$orders = DB::LimitQuery('bonus_order', array(
	'condition' => $condition,
	'order' => 'ORDER BY id DESC',
	'size' => $pagesize,
	'offset' => $offset,
));

foreach($orders as $key =>&$val)
{
	$order_info = Table::Fetch('order', $val['orderid']);
	$val['team_id'] = $order_info['team_id'];
}



$user_ids = Utility::GetColumn($orders, 'user_id');
$users = Table::Fetch('user', $user_ids);

$team_ids = Utility::GetColumn($orders, 'team_id');
$teams = Table::Fetch('team', $team_ids);

include template('manage_bonus_order_index');
